﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace GameCore
{
    public class ViewFrame
    {
        public static bool Lock = true;
        public static Rectangle window = new Rectangle(0, 0, GlobalDefine.Window.ClientBounds.Width,
            GlobalDefine.Window.ClientBounds.Height);
        public static Point MaxSize = new Point(window.Width, window.Height);
        public static Point MaxSpace = new Point(window.Width, window.Height);
        public static void reset()
        {
            window = new Rectangle(0, 0, GlobalDefine.Window.ClientBounds.Width, GlobalDefine.Window.ClientBounds.Height);
        }
        public static void update(Point p_pos)
        {
            if (!Lock)
            {
                if (0 >= p_pos.X-5 || (p_pos.X >= MaxSize.X-5))
                {
                  //  p_pos.X -= window.X;
                    if (p_pos.X <= 0)
                        window.X = window.X <= 10? 0 : window.X - 10;
                        //window.X -=10;

                    int x_temp = p_pos.X - MaxSize.X + 5;
                    if (x_temp >= 0)
                        window.X = window.X >= MaxSpace.X - 10 - window.Width ? MaxSpace.X - window.Width : window.X + 10;
                        //window.X += 10;
                }

                MaxSize.Y = (window.Height / 4) * 3;
                if (0 >= p_pos.Y-5 || (p_pos.Y >= window.Height-5))
                {
                  //  p_pos.Y -= window.Y;

                    if (p_pos.Y <= 0)
                        window.Y = window.Y <= 10 ?  0 : window.Y - 10;
                    //    window.Y += p_pos.Y / 5;

                    int y_temp = p_pos.Y - window.Height + 5;
                    if (y_temp >= 0)
                        window.Y = window.Y >= MaxSpace.Y - 10 - MaxSize.Y ? MaxSpace.Y - MaxSize.Y : window.Y + 10;
                     //   window.Y += y_temp / 5;
                }
                
            }
        }

    }
}
